Much of this material, except for code examples, has been incorporated into the OpenDoc Programmer's Guide for the Mac OS, published by Addison-Wesley.
Selecting the New command from the Document menu instructs the Document Shell subsystem to create a new document with the same kind as the root part of the frontmost window. Note: due to user preferences, the new document may not necessarily be bound to the same editor as the editor of the root part of the frontmost window of the previous document, although it probably will be.
Where is the new document created?
The new document is created in the same folder as the previous document, and its FinderInfo is modified such that it is placed right next to the previous document in its window.
If the Document Shell is unable to create a document in the same folder as the previous document (the volume is full or the folder is read only) then the Document Shell tries to create the new document in each of the following locations one by one. If successful, the Document Shell may also display a dialog noting that the document was created on the desktop of volume x because (there wasn’t enough room in or there were not enough permissions to write to the current folder). If the Document Shell is unable to create the document in any of those locations, then an error is reported to the user (kODErrAllVolumesAreFull).
Secondary locations:
The desktop of the boot volume
- same place that aliases go when they can’t be created in place
The desktop of non-boot local non-removable volumes
- local non-removable is safer than remote or removable
The desktop of non-boot local removable volumes
- local removable is safer than remote
The desktop of non-boot remote volumes.
In all of these cases, from the users’ point of view, the new document is created on their "Desktop" and they can move it from there to their desired location.
What is the new document named?
The new document is named "Page Layout 9/29/94" where "9/29/94" represents the short date when the document was created, and "Page Layout" represents the category of the kind of the root part. If there already was a file with that name in that folder (maybe this is the second document the user is creating in this folder today), then a monotonically increasing number is appended to the name, e.g.
"Page Layout 9/29/94 2"
"Page Layout 9/29/94 3"
...
etc.
Opening stationery in the file system
If the user selects stationery in the file system and chooses Open, or double clicks stationery in the file system, the same algorithm is used for placing the new document; consider the stationery document the "previous document". However, the new document is named "<stationery name> 4/20/95" where "4/20/95" represents the short date when the document was created. If there already was a file with that name in that folder (maybe this is the second document the user is creating in this folder today from that stationery), then a monotonically increasing number is appended to the name as above. The contents of the new document are a clone of the current state of the stationery. The new document does NOT contain any drafts from the stationery document.
Dragging content or a part to the file system
When the user drags a selected piece of content or a selected part to the file system, a new document is created which contains the content or part which was dragged. It is possible that there won't be enough space at the destination of the drop to write the part or content which was dragged. In this case, the drag is canceled and an error is reported to the user (kODErrVolumeIsFull).
If a whole part was dragged to the filesystem, then the new document represents the part which was dragged. The name of this new document is taken from the name of the part. On the Macintosh, filenames are limited to 31 characters, so only the first 31 characters of the part's name are used for the filename. On the Macintosh, two files with the same name cannot exist in the same directory. If there already is a file with the same name as the part then the user is presented with the same alert that she would have seen had she dragged a file into the same destination which had that same name. "An item named ABC already exists in this location. Do you want to replace it with the one you're moving? (Cancel) ((OK))".
If content is dragged, and the source of the drag put a kODPropName property on the DragAndDrop StorageUnit, then that name is used to name the new document, if necessary using the same contingencies as documented above, otherwise the category of the kind of the content is used to name the new document.
If the dragged part has no name (empty name), or the dragged content is not annotated with a name property, then the above algorithm for using the category of the kind of the dragged part is used to name the new document.
Error Conditions
It is possible for the following error conditions to occur while attempting to create a new document:
kODErrAllVolumesAreFull
"There is not enough diskspace to create a new document. Please throw away or compress unnecessary files."
kODErrVolumeIsFull
"Could not move/copy the dragged item because there is not enough diskspace on that volume."
kODErrDirectoryNotHaveWriteAccess
"Could not move/copy the dragged item because you do not have write permission at the destination."